package com.ktgj.pay.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.pay.domain.InvoiceChecking;
import com.ktgj.pay.service.IInvoiceCheckingService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 发票核验Controller
 * 
 * @author ruoyi
 * @date 2022-01-24
 */
@RestController
@RequestMapping("/checking")
public class InvoiceCheckingController extends BaseController
{
    @Autowired
    private IInvoiceCheckingService invoiceCheckingService;

    /**
     * 查询发票核验列表
     */
    @PreAuthorize(hasPermi = "invoice:checking:list")
    @GetMapping("/list")
    public TableDataInfo list(InvoiceChecking invoiceChecking)
    {
        startPage();
        List<InvoiceChecking> list = invoiceCheckingService.selectInvoiceCheckingList(invoiceChecking);
        return getDataTable(list);
    }

    /**
     * 导出发票核验列表
     */
    @PreAuthorize(hasPermi = "invoice:checking:export")
    @Log(title = "发票核验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvoiceChecking invoiceChecking) throws IOException
    {
        List<InvoiceChecking> list = invoiceCheckingService.selectInvoiceCheckingList(invoiceChecking);
        ExcelUtil<InvoiceChecking> util = new ExcelUtil<InvoiceChecking>(InvoiceChecking.class);
        util.exportExcel(response, list, "发票核验数据");
    }

    /**
     * 获取发票核验详细信息
     */
    @PreAuthorize(hasPermi = "invoice:checking:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(invoiceCheckingService.selectInvoiceCheckingById(id));
    }

    /**
     * 新增发票核验
     */
    @PreAuthorize(hasPermi = "invoice:checking:add")
    @Log(title = "发票核验", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvoiceChecking invoiceChecking)
    {
        return toAjax(invoiceCheckingService.insertInvoiceChecking(invoiceChecking));
    }

    /**
     * 修改发票核验
     */
    @PreAuthorize(hasPermi = "invoice:checking:edit")
    @Log(title = "发票核验", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvoiceChecking invoiceChecking)
    {
        return toAjax(invoiceCheckingService.updateInvoiceChecking(invoiceChecking));
    }

    /**
     * 删除发票核验
     */
    @PreAuthorize(hasPermi = "invoice:checking:remove")
    @Log(title = "发票核验", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(invoiceCheckingService.deleteInvoiceCheckingByIds(ids));
    }
}
